import yaml
from config.setting import data_path
def get_yaml_data(file_path):
    with open(file_path, encoding='utf-8') as f:
        return yaml.safe_load(f.read()) # 返回一个字典

def get_yamls_data(file_path): # 获取多段yaml
    with open(file_path, encoding='utf-8') as f:
        return yaml.safe_load_all(f.read()) # 返回一个字典

def set_yaml_data(file_path,data):
    with open(file_path, 'a', encoding='utf-8') as f:
        yaml.safe_dump(data, f)

def set_yamld_data(file_path,data):
    with open(file_path, 'w', encoding='utf-8') as f:
        yaml.safe_dump_all(data, f)


def get_case_data(file_path):
    res_list=[]
    res = get_yaml_data(file_path)
    for one in res:
        res_list.append((one['name'],one['sort'],one['title']))
    #     res_list.append((one['detail'],one['data'],one['resp']))
    return res_list

if __name__ == '__main__':
    print(get_case_data(f'{data_path}/add_dishCategory_fail.yaml'))